﻿Public Class CapNhatThongTinNCC_DAO
    Public Shared Function SelectAll() As DataTable
        Dim dt As DataTable
        Dim strSQL As String = "select * from NhaCungCap"
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
    Public Shared Function SelectByNhaCungCap(_ncc As CapNhatThongTinNCC_DTO) As DataTable
        Dim dt As DataTable
        Dim strSQL As String = "select * from KhachHang where TenNhaCungCap like '%" & _ncc.TenNhaCungCap & "%'"
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
    
    Public Shared Sub Insert(_ncc As CapNhatThongTinNCC_DTO)
        Dim strSQL As String = "Insert into NhaCungCap(MaNhaCungCap,TenNhaCungCap,DiaChi,SoDT,SoFax) values('" & _ncc.MaNhaCungCap & "','" & _ncc.TenNhaCungCap & "','" & _ncc.DiaChi & "'," & _ncc.SoDT & "," & _ncc.SoFax & " )"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
    Public Shared Sub Delete(_ncc As CapNhatThongTinNCC_DTO)
        Dim strSQL As String = "Delete from NhaCungCap where MaNhaCungCap ='" & _ncc.MaNhaCungCap & "'"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub

    Public Shared Sub Update(_ncc As CapNhatThongTinNCC_DTO)
        Dim strSQL As String = "Update NhaCungCap set MaNhaCungCap='" & _ncc.MaNhaCungCap & "' ,TenNhaCungCap='" & _ncc.TenNhaCungCap & "' ,DiaChi='" & _ncc.DiaChi & "',SoDT=" & _ncc.SoDT & ",SoFax=" & _ncc.SoFax & "  where MaNhaCungCap = '" & _ncc.MaNhaCungCap & "'"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
End Class
